package com.zw.mizhe.common.utils;

import android.content.Intent;
import android.os.CountDownTimer;
import android.widget.Button;

import com.zw.mizhe.view.activity.MainActivity;

/**
 * Created by zhangwei on 16/10/22.
 */

public class AdCountDownTimer extends CountDownTimer {
    public Button button;
    String timeStr;

    public AdCountDownTimer(long millisInFuture, long countDownInterval, Button button) {
        super(millisInFuture, countDownInterval);
        this.button = button;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        timeStr = millisUntilFinished / 1000 + "s 跳转主界面";
        button.setText(timeStr);
    }

    @Override
    public void onFinish() {
        timeStr = "0s 跳转主界面";
        button.setText(timeStr);
        button.getContext().startActivity(new Intent(button.getContext(), MainActivity.class));

    }

}
